// 一对一关联
@Select("SELECT u.*, a.* FROM user u LEFT JOIN address a ON u.id = a.user_id WHERE u.id = #{id}")
@Results({
    @Result(property = "id", column = "u.id"),
    @Result(property = "address", column = "a.user_id", 
            one = @One(select = "com.example.mapper.AddressMapper.selectByUserId"))
})
User selectUserWithAddress(Long id);

// 一对多关联
@Select("SELECT * FROM user WHERE id = #{id}")
@Results({
    @Result(property = "id", column = "id"),
    @Result(property = "orders", column = "id", 
            many = @Many(select = "com.example.mapper.OrderMapper.selectByUserId"))
})
User selectUserWithOrders(Long id);